<?php

class m130216_121411_project_material_analyze_init extends CDbMigration
{
	public function safeUp()
	{
		$this->addColumn('erp_user_access', 'projectMaterialAnalyze', 'boolean');
		$this
		->insert('erp_auth_item',
			array(
				'name' => 'projectMaterialAnalyze',
				'type' => CAuthItem::TYPE_ROLE,
				'bizrule' => 'return AccessControl::check("projectMaterialAnalyze");',
			));
		$this
		->insert('erp_auth_item_child',
			array(
				'parent' => 'employee',
				'child' => 'projectMaterialAnalyze',
			));
	}

	public function safeDown()
	{
		$this
		->delete('erp_auth_item_child',
			array(
				'and',
				'parent=:parent',
				'child=:child',
			), array(
				':parent' => 'employee',
				':child' => 'projectMaterialAnalyze',
			));
		$this
		->delete('erp_auth_item', 'name=:name', array(
			':name' => 'projectMaterialAnalyze',
		));
		$this->dropColumn('erp_user_access', 'projectMaterialAnalyze');
	}
}